package com;

import org.apache.cxf.endpoint.Client;
import org.apache.cxf.jaxws.JaxWsServerFactoryBean;
import org.apache.cxf.jaxws.endpoint.dynamic.JaxWsDynamicClientFactory;

import java.util.Arrays;

public class Main {


    public static void main(String[] args) {
        System.out.println("web Service start");
        Test implementor = new Test();
        String address="http://10.192.33.98/helloWorld";
        JaxWsServerFactoryBean factoryBean = new JaxWsServerFactoryBean();
        factoryBean.setAddress(address); //设置暴露地址
        factoryBean.setServiceClass(Test.class); //接口类
        factoryBean.setServiceBean(implementor); //设置实现类
        factoryBean.create();
        System.out.println("web Service started");
    }

    @org.junit.jupiter.api.Test
    public void no() {
        JaxWsDynamicClientFactory dcf = JaxWsDynamicClientFactory.newInstance();
        Client client = dcf.createClient("http://10.192.33.98/helloWorld?wsdl");
        Object[] objects;
        try {
            objects = client.invoke("getList","2");
            System.out.println(Arrays.toString(objects));
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
